package com.supergdtop.www.run.activity.designer;

import android.content.Intent;
import android.text.InputType;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.asum.xlayoutparams.utils.XPxArea;
import com.asum.xuidesign.utils.view.TextViewTools;
import com.supergdtop.www.run.R;
import com.supergdtop.www.run.finaldata.FontSize;
import com.supergdtop.www.run.finaldata.XColor;
import com.supergdtop.www.run.tools.TextTools;
import com.supergdtop.www.run.tools.TextTypefaceTools;

import static java.sql.Types.NULL;

/**
 * 用户登录界面 主页面设计
 * Created by Lemon on 2017/4/5.
 */

public class LoginActivityDesigner extends ActivityDesigner {

    public LinearLayout mainlayout;
    private TextView LoginText;
    private View LineView;
    private ImageView LogoImage;

    public LinearLayout userlayout;
    public ImageView userimage;
    public EditText userid;

    public LinearLayout pwdlayout;
    public ImageView pwdimage;
    public EditText pwd;

    public Button login;


    protected void design(Intent intent) {

    }

    protected void getWidgets() {
        mainlayout = designer.getViewById(R.id.loginlayout);
        LoginText = new TextView(context);
        LineView = new View(context);
        LogoImage = new ImageView(context);

        userlayout = new LinearLayout(context);
        userimage = new ImageView(context);
        userid = new EditText(context);

        pwdlayout = new LinearLayout(context);
        pwdimage = new ImageView(context);
        pwd = new EditText(context);

        login = new Button(context);
    }

    protected void setWidgets() {
        //mainlayout.setBackgroundColor(XColor.RED);


        mainlayout.addView(LoginText);
        LoginText.setText("Welcome To Runbuddy");
        LoginText.setGravity(Gravity.CENTER_HORIZONTAL);
        new TextViewTools(LoginText).textColor(XColor.WHITE).sizePx(FontSize.s24(context));
        new XPxArea(LoginText).set(0,padding*4,XPxArea.MATCH,XPxArea.WRAP);

        mainlayout.addView(LineView);
        LineView.setBackgroundColor(XColor.WHITE);
        new XPxArea(LineView).set(screenW*0.25,padding,screenW*0.5,space*2);

        mainlayout.addView(LogoImage);
        LogoImage.setBackgroundResource(R.drawable.logo);
        LogoImage.setScaleType(ImageView.ScaleType.FIT_CENTER);
        new XPxArea(LogoImage).set(screenW*0.35,padding*4,screenW*0.3,screenW*0.3);

        // 用户名输入框体
        mainlayout.addView(userlayout);
        userlayout.setBackgroundColor(XColor.GRAY);
        userlayout.setOrientation(LinearLayout.HORIZONTAL);
        userlayout.setGravity(Gravity.CENTER_VERTICAL);
        userlayout.setPadding(padding,0,padding,0);
        new XPxArea(userlayout).set(screenW*0.15,screenH*0.15,screenW*0.7,screenW*0.12);

        userlayout.addView(userimage);
        userimage.setScaleType(ImageView.ScaleType.FIT_XY);
        userimage.setBackgroundColor(XColor.WHITE);
        new XPxArea(userimage).set(0,0,padding*2,padding*2);

        userlayout.addView(userid);
        //userid.setCursorVisible(false);
        userid.setGravity(Gravity.CENTER_VERTICAL);
        userid.setBackgroundColor(NULL);
        new TextViewTools(userid).sizePx(FontSize.s18(context)).textColor(XColor.WHITE);
        new XPxArea(userid).set(padding,0,XPxArea.MATCH,XPxArea.WRAP);

        // 密码输入框体
        mainlayout.addView(pwdlayout);
        pwdlayout.setBackgroundColor(XColor.GRAY);
        pwdlayout.setOrientation(LinearLayout.HORIZONTAL);
        pwdlayout.setGravity(Gravity.CENTER_VERTICAL);
        pwdlayout.setPadding(padding,0,padding,0);
        new XPxArea(pwdlayout).set(screenW*0.15,padding,screenW*0.7,screenW*0.12);

        pwdlayout.addView(pwdimage);
        pwdimage.setScaleType(ImageView.ScaleType.FIT_XY);
        pwdimage.setBackgroundColor(XColor.WHITE);
        new XPxArea(pwdimage).set(0,0,padding*2,padding*2);

        pwdlayout.addView(pwd);
        //pwd.setCursorVisible(false);
        pwd.setGravity(Gravity.CENTER_VERTICAL);
        pwd.setBackgroundColor(NULL);
        pwd.setHint("Password");
        pwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        new TextViewTools(pwd).sizePx(FontSize.s18(context)).textColor(XColor.WHITE);
        new XPxArea(pwd).set(padding,0,XPxArea.MATCH,XPxArea.WRAP);

        mainlayout.addView(login);
        login.setText("Sign In");
        login.setBackgroundColor(XColor.GRAY);
        login.setAllCaps(false);
        new TextViewTools(login).sizePx(FontSize.s21(context)).textColor(XColor.WHITE);
        new XPxArea(login).set(screenW*0.15,padding,screenW*0.7,screenW*0.11);
        new TextTypefaceTools().setEnglishTextTypeface(login,context);

    }
}
